<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%
	String path=request.getContextPath();
 	String basePaht=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>导航树</title>
<script type="text/javascript" src="../js/jquery-1.4.min.js"></script>
<style type="text/css">
body {
	margin-left: 9px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
</style>
<script type="text/javascript">
    	$(function(){
    		 //获取当前网址，如： http://localhost:8083/myproj/view/my.jsp
    		   var curWwwPath=window.document.location.href;
    		   //获取主机地址之后的目录，如： myproj/view/my.jsp
    		  var pathName=window.document.location.pathname;
    		  var pos=curWwwPath.indexOf(pathName);
    		  //获取主机地址，如： http://localhost:8083
    		  var localhostPaht=curWwwPath.substring(0,pos);
    		  //获取带"/"的项目名，如：/myproj
    		  var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    		 //得到了 http://localhost:8083/myproj
    		  var realPath=localhostPaht+projectName;
    		 
    		$("#fanhui").click(function(){
    			window.location.href=realPath+"/user/getUserList";
    		});
    		
    		$("#submit").click(function(){
    			var id=$("#userId").val();
    			var ids = "";
    			var lent = $("input[type=checkbox]");
    			for(var i=0;i<lent.length;i++){
    				if(lent[i].checked){
    					ids+=lent[i].value+",";
    				}
    			}
    			window.location.href=realPath+"/user/updateRoleList?id="+id+"&ids="+ids;
    		});
    	})
    </script>
</head>
<body style="overflow:hidden">
<div style="margin-left: 300px;margin-top: 5%;margin-right: 300%px;">
<input type="hidden" id="userId" value="${id}"/>
 <table width="50%" height="100%" border="0" cellpadding="0" cellspacing="0" style="table-layout:fixed">
   <tr>
     <td valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
		<TR>
			<TD vAlign=top align=middle>
				 <c:forEach items="${result}" var="key" varStatus="stut">
					<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
						<TR height=22>
							<TD style="PADDING-LEFT: 30px">
								<input type="checkbox"  value="${key.id}" <c:if test="${key.relSysUserId ne null}">checked="checked"</c:if>/><span class=menuParent onclick='expand("${stut.index}")'><font>${key.roleName}</font>
								</span>
							</TD>
						</TR>
					</TABLE>
				</c:forEach> 
			</TD>
			<TD width=1 bgColor=#d1e6f7></TD>
		</TR>
        </table></td>
      </tr>
      <tr> 
      	<td height="20"><input type="button" id="submit" value="确定"/> <input type="button" id="fanhui" value="返回"/></td>      
      </tr>
    </table></td>
  </tr>
</table>
</div>
</body>
</html>